package cn.zswltech.gruul;

import cn.zswltech.gruul.common.util.AESUtil;
import cn.zswltech.gruul.web.api.util.RequestUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.spring.annotation.MapperScan;

import javax.servlet.http.HttpServletRequest;

@SpringBootApplication(scanBasePackages = {"cn.zswltech"})
@MapperScan(basePackages = {"cn.zswltech.gruul.common.dal.dao","cn.zswltech.lib.futurelog.save.mapper"})
//@EnableFeignClients
//@EnableDiscoveryClient
@Slf4j
@RestController
public class GruulApplication {

    public static void main(String[] args) {
        SpringApplication.run(GruulApplication.class, args);
    }

    @Bean
    public AESUtil aesUtil(){
        return new AESUtil();
    }

    @RequestMapping({"/api/ok", "/api/ok.htm", "/api/ok.html"})
    String ok() {
        return "ok";
    }

    @RequestMapping({"version"})
    String version(HttpServletRequest request) {
        String requestIp = RequestUtil.getIpAddr(request);
        log.info("2023-07-28 15:00, clientIp:" + requestIp);
        return "2023-07-28 15:00, clientIp:" + requestIp;
    }

}
